package com.sgcc.nfc.lock.data.remote.dto.warning

import com.google.gson.annotations.SerializedName
import com.sgcc.nfc.lock.domain.model.Warning
import com.sgcc.nfc.lock.domain.model.WarningStatus
import com.sgcc.nfc.lock.domain.model.WarningType

data class WarningDto(
    @SerializedName("warningId") val warningId: Long?,
    @SerializedName("warningType") val warningType: Int?,
    @SerializedName("lockId") val lockId: Long?,
    @SerializedName("roomId") val roomId: Long?,
    @SerializedName("roomName") val roomName: String?,
    @SerializedName("warningContent") val warningContent: String?,
    @SerializedName("unlockDuration") val unlockDuration: Long?,
    @SerializedName("status") val status: Int?,
    @SerializedName("handleUserId") val handleUserId: Long?,
    @SerializedName("handleUserName") val handleUserName: String?,
    @SerializedName("handleTime") val handleTime: String?,
    @SerializedName("createTime") val createTime: String?
) {
    fun toDomain(): Warning = Warning(
        warningId = warningId ?: 0L,
        warningType = WarningType.from(warningType),
        lockId = lockId,
        roomId = roomId,
        roomName = roomName,
        warningContent = warningContent,
        unlockDuration = unlockDuration,
        status = WarningStatus.from(status),
        handleUserId = handleUserId,
        handleUserName = handleUserName,
        handleTime = handleTime,
        createTime = createTime
    )
}
